package com.example.doctorsystem.controller;

import com.example.doctorsystem.model.Doctor;
import com.example.doctorsystem.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/doctors")
public class DoctorController {

    @Autowired
    private DoctorService doctorService;

    @PostMapping("/register")
    public String register(@RequestBody Doctor doctor) {
        int result = doctorService.register(doctor);
        return result > 0 ? "注册成功" : "注册失败";
    }

    @PostMapping("/login")
    public Doctor login(@RequestParam String email, @RequestParam String password) {
        return doctorService.login(email, password);
    }

    @GetMapping
    public List<Doctor> allDoctors() {
        return doctorService.getAllDoctors();
    }
}

